export function getPolarBarOption (data, color, config) {
  let label = []
  color = color || '#806EFA'
  const opt = Object.assign({
    label: [],
    axisLabelSize: 8,
    axisValueSize: 8
  }, config)
  let max = 0
  if (opt.label.length) {
    label = opt.label
  } else {
    for (let i = 0; i < data.length; i++) {
      let item = data[i]
      label.push(item.name)
      if (item.value > max) max = item.value
    }
  }
  return {
    polar: {
    },
    radiusAxis: {
      boundaryGap: true,
      axisLabel: {
        color: '#989898',
        fontSize: opt.axisValueSize
      },
      splitLine: {
        lineStyle: {
          color: '#7F7FB5'
        }
      },
      axisLine: {
        lineStyle: {
          color: '#7F7FB5'
        }
      }
    },
    angleAxis: {
      type: 'category',
      axisLabel: {
        color: '#989898',
        fontSize: opt.axisLabelSize
      },
      axisLine: {
        lineStyle: {
          color: '#7F7FB5'
        }
      },
      data: label
    },
    series: [{
      type: 'bar',
      itemStyle: {
          color: 'transparent'
      },
      data: data.map((item) => max / 10),
      coordinateSystem: 'polar',
      stack: 'minBar',
      silent: true
  }, {
      type: 'bar',
      itemStyle: {
        color
      },
      coordinateSystem: 'polar',
      stack: 'minBar',
      data: data
    }]
  }
}
